from tortoise import fields
from tortoise.models import Model


class Wise_Counsel(Model):
    id = fields.IntField(pk=True)
    name = fields.CharField(max_length=255, description="名称")
    introduction = fields.TextField(description="简介")
    cover = fields.CharField(max_length=255, description="封面")
    audio = fields.CharField(max_length=255, description="音频")
    passage = fields.TextField(description="音频对应文稿")
    difficulty = fields.CharField(max_length=255, description="难度")
    month_range = fields.CharField(max_length=255, description="锦囊妙计对应月龄段")
    practiced = fields.SmallIntField(description="是(1)否(0)实践")
    explore_id = fields.IntField(description="该锦囊所属探索的问题id")
    explore_counsel_order = fields.DatetimeField(auto_now_add=True, description="所在探索中锦囊排序")
    update_time = fields.DatetimeField(auto_now_add=True, description="锦囊更新时间")

    def __str__(self):
        return self.id

    class Meta:
        db_table = "wise_counsel"
        table_description = "锦囊妙计表"


class Counsel_Practice_Method(Model):
    id = fields.IntField(pk=True)
    counsel_id = fields.IntField(description="锦囊id")
    method_id = fields.IntField(description="方法序号")
    method_name = fields.CharField(max_length=255, description="方法名称")

    def __str__(self):
        return self.id

    class Meta:
        db_table = "counsel_practice_method"
        table_description = "锦囊实践方法表"


class Practice_Method_Card(Model):
    id = fields.IntField(pk=True)
    practice_method_id = fields.IntField(description="实践方法id")
    practice_method_card = fields.IntField(description="方法卡片")

    def __str__(self):
        return self.id

    class Meta:
        db_table = "practice_method_card"
        table_description = "实践方法卡片表"


class Counsel_Evaluation(Model):
    id = fields.IntField(pk=True)
    counsel_id = fields.IntField(description="锦囊id")
    gauge_id = fields.IntField(description="量表编号")
    recommendation = fields.CharField(max_length=255, description="推荐语")

    def __str__(self):
        return self.id

    class Meta:
        db_table = "counsel_evaluation"
        table_description = "锦囊关联测评表"


class User_Counsel(Model):
    id = fields.IntField(pk=True)
    user_id = fields.IntField(description="用户id")
    baby_id = fields.IntField(description="宝贝id")
    counsel_id = fields.IntField(description="锦囊id")
    explore_id = fields.IntField(description="所属探索id")
    mentality_status = fields.SmallIntField(description="省心状态，不省心0 省心1")

    def __str__(self):
        return self.id

    class Meta:
        db_table = "user_counsel"
        table_description = "用户锦囊表"


class User_FeedBack(Model):
    id = fields.IntField(pk=True)
    user_id = fields.IntField(description="用户id")
    baby_id = fields.IntField(description="宝贝id")
    feedback_content = fields.TextField(description="反馈内容")
    explore_id = fields.IntField(description="所属探索id")
    feedback_time = fields.DatetimeField(auto_now_add=True, description="反馈时间")

    def __str__(self):
        return self.id

    class Meta:
        db_table = "user_feedback"
        table_description = "用户反馈表"

